<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="4" :lg="4" :md="4" :sm="20">
            <a-form-item label="姓名">
              <a-input placeholder="医生姓名" v-model="queryParam.name"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="4" :lg="4" :md="4" :sm="20">
            <a-form-item label="手机号">
              <a-input placeholder="手机号" v-model="queryParam.phone"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="4" :lg="4" :md="4" :sm="20">
            <a-form-item label="状态">
              <a-select v-model="queryParam.status" placeholder="请选择状态">
                <a-select-option value="1">启用</a-select-option>
                <a-select-option value="0">不启用</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>

          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
<!--      <a-button type="primary" icon="download" @click="handleExportXls('doctor_register_hospital')">导出</a-button>-->
<!--      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">-->
<!--        <a-button type="primary" icon="import">导入</a-button>-->
<!--      </a-upload>-->
<!--      <a-dropdown v-if="selectedRowKeys.length > 0">-->
<!--        <a-menu slot="overlay">-->
<!--          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>-->
<!--        </a-menu>-->
<!--        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>-->
<!--      </a-dropdown>-->
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>

        <span slot="status" slot-scope="text, record">
            <span v-if="record.status == 1">
               <a-button  @click="statusUpt(record)" type="primary">启用中</a-button>
            </span>
            <span v-else>
               <a-button  @click="statusUpt(record)">停用中</a-button>
            </span>
        </span>
        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>
          <a-divider type="vertical" />
          <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
            <a>删除</a>
          </a-popconfirm>
        </span>

      </a-table>
    </div>

    <doctor-register-operate-modal ref="modalForm" @ok="modalFormOk"></doctor-register-operate-modal>
<!--    <doctor-register-operate-add-modal ref="DoctorRegisterOperateAdd"></doctor-register-operate-add-modal>-->
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import DoctorRegisterOperateModal from './DoctorRegisterOperateModal'
  // import DoctorRegisterOperateAddModal from './modules/DoctorRegisterOperateAddModal'
  import { getAction, httpAction } from '../../api/manage'

  export default {
    name: 'DoctorRegisterOperateList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      DoctorRegisterOperateModal,
      // DoctorRegisterOperateAddModal
    },
    data () {
      return {
        description: '运营管理',
        // 表头
        columns: [
          {
            title:'运营id',
            align:"center",
            dataIndex: 'id'
          },
          {
            title:'姓名',
            align:"center",
            dataIndex: 'name'
          },
          {
            title:'电话',
            align:"center",
            dataIndex: 'phone'
          },
          {
            title:'部门',
            align:"center",
            dataIndex: 'department'
          },
          {
            title:'备注',
            align:"center",
            dataIndex: 'remark',
            customRender:function (text) {
              return !text?"":(text.length>16?text.substr(0,16):text)
            }
          },
          {
            title:'启用状态',
            align:"center",
            scopedSlots: { customRender: 'status' },
          },
          {
            title:'创建时间',
            align:"center",
            dataIndex: 'createTime',
            customRender:function (text) {
              return !text?"":(text.length>16?text.substr(0,16):text)
            }
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/doctorRegisterOperate/doctorRegisterOperate/list",
          edit: "/doctorRegisterOperate/doctorRegisterOperate/edit",
          delete: "/doctorRegisterOperate/doctorRegisterOperate/delete",
          deleteBatch: "/doctorRegisterOperate/doctorRegisterOperate/deleteBatch",
          exportXlsUrl: "/doctorRegisterOperate/doctorRegisterOperate/exportXls",
          importExcelUrl: "doctorRegisterOperate/doctorRegisterOperate/importExcel",
          
        },
        dictOptions:{},
      }
    },
    created() {
    },
    // computed: {
    //   importExcelUrl: function(){
    //     return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    //   },
    // },
    methods: {
      //更改启用状态
      statusUpt(record){
        var that = this
        if(record.status == 1){
          record.status = 0
        }else{
          record.status = 1
        }

        httpAction(this.url.edit,record,"put").then((res)=>{
          if(res.success){
            that.$message.success("成功");
          }else{
            that.$message.warning(res.message);
          }
        })
      },
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>